#include "junix.h"

static struct option const longoptions[]=
{
	{"hello",no_argument,NULL,'h'},
	{"world",required_argument,NULL,'w'},
	{"junix",optional_argument,NULL,'j'},
	{NULL,0,NULL,0}
};


int main(int argc, char **argv)
{
	int ch;

	while( (ch=getopt_long(argc,argv,"j::w:h",longoptions,NULL)) != -1)
	{
		switch (ch)
		{
			case 'h':
				fprintf(stdout,"-h or --hello\n");
				fflush(stdout);
				break;
			case 'w':
				fprintf(stdout,"-w or --world\n");
				fprintf(stdout,"required_argument:%s\n",optarg);
				fflush(stdout);
				break;
			case 'j':
				fprintf(stdout,"-j or --junix\n");
				if(optarg)
					fprintf(stdout,"optional_argument:%s\n",optarg);
				fflush(stdout);
				break;
			case '?':
				fprintf(stdout,"unknow options\n");
				fflush(stdout);
				break;
		}
	}
	return 0;
}

